<?php

namespace zhtfrontend\models\datas;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
use zhtfrontend\components\bases\BaseModel;

/**
 * This is the model class for table "{{%admin_log}}".
 *
 * @property integer $id
 * @property integer $admin_id
 * @property string $url
 * @property string $description
 * @property string $type
 * @property integer $created_at
 * @property string $operate_ip
 */
class AdminLog extends BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%admin_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['admin_id', 'created_at'], 'integer'],
            [['url', 'description'], 'string', 'max' => 200],
            [['type'], 'string', 'max' => 10],
            [['operate_ip'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('zhtfrontend', '自动编号'),
            'admin_id' => Yii::t('zhtfrontend', '管理员id'),
            'url' => Yii::t('zhtfrontend', '操作地址'),
            'description' => Yii::t('zhtfrontend', '描述'),
            'type' => Yii::t('zhtfrontend', '操作类型'),
            'created_at' => Yii::t('zhtfrontend', '操作时间'),
            'operate_ip' => Yii::t('zhtfrontend', '操作ip地址'),
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],

                ],
            ],

        ]);
    }
}
